﻿using System;
using System.Collections.Generic;
using System.ServiceModel;
using BusinessLogicLibrary;
using entities;

namespace ServiceLibrary
{
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class ManagerService : IManagerService
    {
        private readonly EmployeeModule _employee = new EmployeeModule();
        private readonly PromotionModule _promotion = new PromotionModule();
        private readonly RoomModule _room = new RoomModule();
        private readonly SupplyModule _supply = new SupplyModule();

        #region"EMPLOYEE Management"

        public bool EmpEmailCheck(string email)
        {
            return _employee.CheckEmployeeEmail(email);
        }

        public string EmpAdd(string name, bool sex, DateTime birthday, string position, string phone, string email,
                             string address, string city, string country, string jobtitle, byte[] image)
        {
            return _employee.AddEmployee(name, sex, birthday, position, phone, email, address, city, country,
                                         jobtitle, image);
        }

        public string EmpModify(int employeeID, string name, bool sex, DateTime birthday, string position,
                                string phone, string email, string address, string city, string country, string jobtitle,
                                byte[] image)
        {
            return _employee.ModifyEmployee(employeeID, name, sex, birthday, position, phone, email, address,
                                            city, country, jobtitle, image);
        }

        public string EmpDeactive(int employeeID)
        {
            return _employee.DeactiveEmployee(employeeID);
        }

        public List<vEmployeeSubDetail> EmpGet(bool all)
        {
            return _employee.GetEmployee(all);
        }

        public Employee EmpGetById(int employeeID)
        {
            Employee employee = _employee.GetEmployeeById(employeeID);
            return employee;
        }

        public List<vEmployeeSubDetail> EmpSearchByName(string val)
        {
            return _employee.SearchEmployeeByName(val);
        }

        #endregion

        #region "ROOM Management"

        public string EquAdd(string name, decimal price, bool available)
        {
            return _room.AddEquipment(name, price, available);
        }

        public List<EquipmentDetail> EquGet(bool available)
        {
            return _room.GetEquipment(available);
        }

        public EquipmentDetail EquGetByID(int id)
        {
            return _room.GetEquipmentByID(id);
        }

        public List<EquipmentDetail> EquGetByName(string name)
        {
            return _room.GetEquipmentByName(name);
        }

        public string EquModify(int id, string name, decimal price, bool available)
        {
            return _room.ModifyEquipment(id, name, price, available);
        }

        public RoomType RoTyGetByID(int id)
        {
            return _room.GetRoomTypeByID(id);
        }

        public List<RoomType> RoTyGet()
        {
            return _room.GetRoomType();
        }

        public List<EquipmentDetail> EquGetByRoomTypeID(int id)
        {
            return _room.GetEquipmentByRoomTypeID(id);
        }

        public string RoTyAdd(string title, string rank, decimal price, bool bath, bool view, bool balcon,
                              List<int> equipmentDetailID)
        {
            return _room.AddRoomType(title, rank, price, bath, view, balcon, equipmentDetailID);
        }

        public string RoTyModify(int id, string title, string rank, decimal price, bool bath, bool view,
                                 bool balcony, List<int> equipmentDetailId)
        {
            return _room.ModifyRoomType(id, title, rank, price, bath, view, balcony, equipmentDetailId);
        }


        public List<Room> RooGet(int available)
        {
            return _room.GetRoom(available);
        }

        public Room RooGetByID(int id)
        {
            return _room.GetRoomByID(id);
        }

        public List<Room> RooGetByRoTyID(int roomTypeId)
        {
            return _room.GetRoomByRoomTypeID(roomTypeId);
        }

        public string RooAdd(int roomId, int status, int roomTypeId)
        {
            return _room.AddRoom(roomId, status, roomTypeId);
        }

        public string RooModify(int roomId, int status, int roomTypeId)
        {
            return _room.ModifyRoom(roomId, status, roomTypeId);
        }

        #endregion

        #region "SUPPLY Management"

        public string SupDetailAdd(bool available, string supplyName, decimal price, string unit)
        {
            return _supply.AddSupplyDetail(available, supplyName, price, unit);
        }

        public string SupDetailModify(int id, bool available, string supplyName, decimal price, string unit)
        {
            return _supply.ModifySupplyDetail(id, available, supplyName, price, unit);
        }

        public List<SupplyDetail> SupDetailGet(bool available)
        {
            return _supply.GetSupplyDetail(available);
        }

        public SupplyDetail SupDetailGetById(int id)
        {
            return _supply.GetSupplyDetailByID(id);
        }

        public List<SupplyDetail> SupDetailGetByName(string name)
        {
            return _supply.GetSupplyDetailByName(name);
        }

        #endregion

        #region "PROMOTION Management"

        public List<vSubPromotion> ProGet(bool available)
        {
            return _promotion.GetPromotion(available);
        }

        public Promotion ProGetById(int id)
        {
            return _promotion.GetPromotion(id);
        }

        public List<vSubPromotion> ProGetByTitle(string title)
        {
            return _promotion.GetPromotion(title);
        }

        public List<vSubPromotion> ProGetByTime(DateTime startTime, DateTime endTime)
        {
            return _promotion.GetPromotion(startTime, endTime);
        }

        public string ProAdd(DateTime startTime, DateTime endTime, string title, string desciption, byte[] banner)
        {
            return _promotion.AddPromotion(startTime, endTime, title, desciption, banner);
        }

        public string ProModify(int promotionId, DateTime startTime, DateTime endTime, string title, string desciption,
                                byte[] banner)
        {
            return _promotion.ModifyPromotion(promotionId, startTime, endTime, title, desciption, banner);
        }

        public string ProRemove(int id)
        {
            return _promotion.removePromotion(id);
        }

        public List<vSubPromotionDetail> ProDetailGetByProId(int id)
        {
            return _promotion.GetPromotionDetailByPromotionId(id);
        }

        public PromotionDetail ProDetailGetById(int id)
        {
            return _promotion.GetPromotionDetail(id);
        }

        public string ProDetailAdd(int promotionId, string promotionContent, byte[] promotionImage)
        {
            return _promotion.AddPromotionDetail(promotionId, promotionContent, promotionImage);
        }

        public string ProDetailModify(int promotionDetailId, string promotionContent, byte[] promotionImage)
        {
            return _promotion.ModifyPromotionDetail(promotionDetailId, promotionContent, promotionImage);
        }

        public string ProDetailRemove(int promotionDetailId)
        {
            return _promotion.RemovePromotionDetail(promotionDetailId);
        }

        #endregion
    }


    [ServiceContract]
    public interface IManagerService
    {
        #region EMPLOYEE Management

        [OperationContract]
        bool EmpEmailCheck(string email);

        [OperationContract]
        string EmpAdd(string name, bool sex, DateTime birthday, string position, string phone, string email,
                      string address, string city, string country, string jobtitle, byte[] image);

        [OperationContract]
        string EmpModify(int employeeID, string name, bool sex, DateTime birthday, string position, string phone,
                         string email, string address, string city, string country, string jobtitle, byte[] image);

        [OperationContract]
        string EmpDeactive(int employeeID);

        [OperationContract]
        List<vEmployeeSubDetail> EmpGet(bool all);

        [OperationContract]
        Employee EmpGetById(int employeeID);

        [OperationContract]
        List<vEmployeeSubDetail> EmpSearchByName(string val);

        #endregion

        #region ROOM Management

        [OperationContract]
        string EquAdd(string name, decimal price, bool available);

        [OperationContract]
        List<EquipmentDetail> EquGet(bool available);

        [OperationContract]
        EquipmentDetail EquGetByID(int id);

        [OperationContract]
        List<EquipmentDetail> EquGetByName(string name);

        [OperationContract]
        List<EquipmentDetail> EquGetByRoomTypeID(int id);

        [OperationContract]
        string EquModify(int id, string name, decimal price, bool available);

        [OperationContract]
        RoomType RoTyGetByID(int id);

        [OperationContract]
        List<RoomType> RoTyGet();

        [OperationContract]
        string RoTyAdd(string title, string rank, decimal price, bool bath, bool view, bool balcon,
                       List<int> equipmentDetailID);

        [OperationContract]
        string RoTyModify(int id, string title, string rank, decimal price, bool bath, bool view,
                          bool balcony, List<int> equipmentDetailId);

        [OperationContract]
        List<Room> RooGet(int available);

        [OperationContract]
        Room RooGetByID(int id);

        [OperationContract]
        List<Room> RooGetByRoTyID(int roomTypeId);

        [OperationContract]
        string RooAdd(int roomId, int status, int roomTypeId);

        [OperationContract]
        string RooModify(int roomId, int status, int roomTypeId);

        #endregion

        #region "SUPPLY Management"

        [OperationContract]
        string SupDetailAdd(bool available, string supplyName, decimal price, string unit);

        [OperationContract]
        string SupDetailModify(int id, bool available, string supplyName, decimal price, string unit);

        [OperationContract]
        List<SupplyDetail> SupDetailGet(bool available);

        [OperationContract]
        SupplyDetail SupDetailGetById(int id);

        [OperationContract]
        List<SupplyDetail> SupDetailGetByName(string name);

        #endregion

        #region "PROMOTION Management"

        [OperationContract]
        List<vSubPromotion> ProGet(bool available);

        [OperationContract]
        Promotion ProGetById(int id);

        [OperationContract]
        List<vSubPromotion> ProGetByTitle(string title);

        [OperationContract]
        List<vSubPromotion> ProGetByTime(DateTime startTime, DateTime endTime);

        [OperationContract]
        string ProAdd(DateTime startTime, DateTime endTime, string title, string desciption, byte[] banner);

        [OperationContract]
        string ProModify(int promotionId, DateTime startTime, DateTime endTime, string title, string desciption,
                         byte[] banner);

        [OperationContract]
        string ProRemove(int id);

        [OperationContract]
        List<vSubPromotionDetail> ProDetailGetByProId(int id);

        [OperationContract]
        PromotionDetail ProDetailGetById(int id);

        [OperationContract]
        string ProDetailAdd(int promotionId, string promotionContent, byte[] promotionImage);

        [OperationContract]
        string ProDetailModify(int promotionDetailId, string promotionContent, byte[] promotionImage);

        [OperationContract]
        string ProDetailRemove(int promotionDetailId);

        #endregion
    }
}